package com.biz.primus.ms.member.listener;

import com.biz.primus.ms.member.event.LoginEvent;
import com.biz.primus.ms.member.service.MemberAddressService;
import com.biz.primus.ms.member.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * Created by liangbin on 2017/11/27.
 */
@Component
public class LoginListener extends AbstractBizEventListener<LoginEvent>{
    @Autowired
    MemberAddressService memberAddressService;

    @Override
    @TransactionalEventListener
    protected void handleEvent(LoginEvent event) {
        Long memberId = event.getMemberId();
        if (memberId != null) {
            memberAddressService.initAddressLabel(memberId);
        }


    }
}
